import {
  BaseCascader,
  BaseSelect,
  BaseSelectV2,
  BaseTreeSelect
} from '@pkgs/components'
import useMicroStore from '@apps/_share/store/micro'

const { $t } = useMicroStore()

export const schemas = [
  {
    title: $t('BaseSelect:'),
    field: 'status',
    column: 1,
    component: {
      vm: markRaw(BaseSelect),
      value: '',
      props: {
        api: async () => [{
          label: '开启',
          value: '1',
        }, {
          label: '关闭',
          value: '2',
        }],
        apiParams: {
          a: 1,
          b: 2,
        },
        multiple: true,
        placeholders: $t('全部'),
      },
      listeners: {
        change(v: string) {
          console.log('change>>>>', v)
        },
      },
    },
  },
  {
    title: $t('BaseSelectV2:'),
    field: 'status1',
    column: 1,
    component: {
      vm: markRaw(BaseSelectV2),
      value: '',
      props: {
        options: [{ label: 'test-1', value: 1 }, { label: 'test-2', value: 2 }],
        multiple: true,
        placeholders: $t('全部'),
      },
      listeners: {
        change(v: string) {
          console.log('change>>>>', v)
        },
      },
    },
  },
  {
    title: $t('BaseCascader:'),
    field: 'status1',
    column: 1,
    component: {
      vm: markRaw(BaseCascader),
      value: '',
      props: {
        options: [
          { label: 'test-1', value: 1, children: [] },
          {
            label: 'test-2',
            value: 2,
            children: [{ label: 'test-2-2', value: 22, children: [] }],
          },
        ],
        multiple: true,
        placeholders: $t('全部'),
      },
      listeners: {
        change(v: string) {
          console.log('change>>>>', v)
        },
      },
    },
  },
  {
    title: $t('BaseTreeSelect:'),
    field: 'status1',
    column: 1,
    component: {
      vm: markRaw(BaseTreeSelect),
      value: '',
      props: {
        options: [
          { label: 'test-1', value: 1, children: [] },
          {
            label: 'test-2',
            value: 2,
            children: [{ label: 'test-2-2', value: 22, children: [] }],
          },
        ],
        multiple: true,
        placeholders: $t('全部'),
      },
      listeners: {
        change(v: string) {
          console.log('change>>>>', v)
        },
      },
    },
  },
]

export const columns = [
  {
    prop: 'product',
    label: $t('商品'),
    align: 'center',
    slot: 'product',
    minWidth: 250,
  },
  {
    prop: 'createTime',
    label: $t('创建时间'),
    align: 'center',
    minWidth: 200,
  },
  {
    prop: 'createName',
    label: $t('创建人'),
    align: 'center',
    minWidth: 120,
  },
  {
    prop: 'modifyTime',
    label: $t('修改时间'),
    align: 'center',
    minWidth: 200,
  },
  {
    prop: 'modifyName',
    label: $t('修改人'),
    align: 'center',
    minWidth: 120,
  },
  {
    label: $t('操作'),
    slot: 'operation',
    align: 'center',
    fixed: 'right',
    minWidth: 170,
  },
]
